




C Functions Test 1

1) What is the built-in library function for comparing the two strings?

strcmp()
equals()
str_compare()
string_cmp()

Show Answer

The correct option is (a).
Explanation:
The strcmp() is a built-in function available in "string.h" header file. It is used for comparing the two strings. It returns 0 if both are same strings. It returns positive value greater than 0 if first string is greater than second string, otherwise it returns negative value.

2) What is passed when we pass an array as a function argument?

Base address of an array
Address of the last element of array
First value of elements in array
All value of element in array

Show Answer

The correct option is (a).
Explanation:
On passing the name of array as function argument; the name contain the base address of an array and base address is updated inside a main function.

3) Which function finds the first occurrence of a substring in another string?

strchr()
strnset()
strstr()
None of these.

Show Answer

The correct option is (c).
Explanation:
The first occurrence of a substring in another string is founds in strstr() function.

4) What is the built-in library function for adjusting the allocated dynamic memory size.

calloc
malloc
realloc
resize

Show Answer

The correct option is (c).
Explanation:
realloc() is a built in library function for adjusting the dynamic memory size. malloc() and calloc() allocates the memory but don't resize. There is no built in function with a name resize().

5) Which keyword is used to transfer control from a function back to the calling function?

return
go back
switch
goto

Show Answer

The correct option is (a).
Explanation:
In C language, the return function stops the execution of function and returns a value to calling function. Execution is begins in a calling function by instantly following the call.












Please Share





